import Vue from 'vue'
import Router from 'vue-router'
// in development env not use Lazy Loading,because Lazy Loading too many pages will cause webpack hot update too slow.so only in production use Lazy Loading
/* layout */
import Layout from '../views/layout/Layout'

const _import = require('./_import_' + process.env.NODE_ENV)
Vue.use(Router)
export const constantRouterMap = [
  {path: '/login', component: _import('login/index'), hidden: true},
  {path: '/404', component: _import('404'), hidden: true},
  {
    path: '/',
    component: Layout,
    redirect: '/dashboard',
    name: '首页',
    hidden: true,
    children: [{
      path: 'dashboard', component: _import('dashboard/index')
    }]
  },{
    path: '/user',
    component: Layout,
    name: '',
    hidden: true,
    meta: {title: '我的文章', icon: 'table'},
    children: [
      {
        path: 'details',
        name: 'details',
        component: _import('article/details'),
        meta: {title: '详情', icon: 'details'},
        menu: 'article'
      },
    ]
  },
]
export default new Router({
  // mode: 'history', //后端支持可开
  scrollBehavior: () => ({y: 0}),
  routes: constantRouterMap
})
export const asyncRouterMap = [
  {
    path: '/authorFirstPage',
    component: Layout,
    name: 'user',
    meta: {title: '我的', icon: 'table'},
    children: [
      {
        path: 'author',
        name: '',
        component: _import('user/author'),
        meta: {title: '作者首页', icon: 'user'},
        menu: 'article'
      }
    ]
  },
  {
    path: '/myArticle',
    component: Layout,
    name: 'user',
    meta: {title: '我的文章', icon: 'table'},
    children: [
      {
        path: 'article',
        name: '',
        component: _import('user/article'),
        meta: {title: '已完成文章', icon: 'table'},
        menu: 'role'
      },
    ]
  },
  
  
  {
    path: '/declare',
    component: Layout,
    name: 'system',
    meta: {title: '申报', icon: 'tree'},
    children: [
      {
        path: 'apply',
        name: '',
        component: _import('apply/apply'),
        meta: {title: '申报申请', icon: 'example'},
        menu: 'apply'
      },
    ]
  },
  {
    path: '/allArticle',
    component: Layout,
    name: '',
    meta: {title: '文章', icon: 'tree'},
    children: [
      {
        path: 'all',
        name: 'all',
        component: _import('article/all'),
        meta: {title: '所有文章', icon: 'tree'},
        menu: 'article'
      },
    ]
  },
  {
    path: '/analyst',
    component: Layout,
    name: '',
    meta: {title: '文章', icon: 'tree'},
    children: [
      {
        path: 'senior-analyst',
        name: 'senior-analyst',
        component: _import('article/senior-analyst'),
        meta: {title: '高级分析师文章', icon: 'super'},
        menu: 'article'
      },
    ]
  },
  {
    path: '/text',
    component: Layout,
    name: '',
    meta: {title: '文章', icon: 'tree'},
    children: [
      {
        path: 'text-edit',
        name: 'text-edit',
        component: _import('article/text-edit'),
        meta: {title: '副总编文章', icon: 'text'},
        menu: 'article'
      },
    ]
  },
  {
    path: '/editor',
    component: Layout,
    name: '',
    meta: {title: '文章', icon: 'tree'},
    children: [
      {
        path: 'chief-editor',
        name: 'chief-editor',
        component: _import('article/chief-editor'),
        meta: {title: '总编文章', icon: 'chief'},
        menu: 'article'
      },
    ]
  },  
   
  {
    path: '/releasedPool',
    component: Layout,
    name: '',
    meta: {title: '文章', icon: 'tree'},
    children: [
      {
        path: 'article-pool',
        name: 'article-pool',
        component: _import('article/article-pool'),
        meta: {title: '待发布文章池', icon: 'release'},
        menu: 'article'
      },
    ]
  },  
  {
    path: '/releasedArticle',
    component: Layout,
    name: '',
    meta: {title: '文章', icon: 'tree'},
    children: [
      {
        path: 'article-release',
        name: 'article-release',
        component: _import('article/article-release'),
        meta: {title: '待发布文章', icon: 'release'},
        menu: 'article'
      },
    ]
  }, 
  {
    path: '/user',
    component: Layout,
    name: '',
    meta: {title: '系统管理', icon: 'setting', roles: ['admin']},
    children: [
      {
        path: 'user', name: '用户列表', component: _import('system/user'), meta: {title: '用户列表', icon: 'users'}, menu: 'user'
      },
    ]
  },
  {
    path: '/role',
    component: Layout,
    name: '',
    meta: {title: '系统管理', icon: 'setting', roles: ['admin']},
    children: [
      {
        path: 'role',
        name: '权限管理',
        component: _import('system/role'),
        meta: {title: '权限管理', icon: 'authority', roles: ['admin']},
        menu: 'role'
      },
    ]
  },
  {
    path: '/operationLog',
    component: Layout,
    name: '',
    meta: {title: '系统管理', icon: 'setting', roles: ['admin']},
    children: [
      {
        path: 'oplog',
        name: 'oplog',
        component: _import('system/oplog'),
        meta: {title: '操作日志', icon: 'log'},
        menu: 'article'
      }
    ]
  },


  {path: '*', redirect: '/404', hidden: true}
]
